<?php
//booooody al3b hennaaaaa :D
//ps: adeek yalla
function displayProduct($row){
     $count=count($row);
     for($i=0;$i < $count;$i++){   
    echo "<div class=show >";
    $proID= $row[$i]['proID'];
     echo  "<a href="."showProducts.php?action=showProductInfo&Pid=$proID"."><img src='".$row[$i]['proImage']."' width=150 height=150  /></a><br>" . " " . $row[$i]['stID']." ". $row[$i]['proID'];
     echo "<br>";	
      echo "</div>";
     }
}
$flag=FALSE;
//process posted form data
if(!empty($_POST['category'])) {
   
	$category = trim(strip_tags($_POST['category']));
	$storeID = trim(strip_tags($_POST['storeID']));
       
	include 'productClass.php';
        $pr=new Product();
       $result= $pr->displayProductsByCategory($storeID, $category);
	displayProduct($result);
}
else if(@$_GET['action']=="showProducts"){
       
    
     $StID= $_GET['Sid'];
    
    include './productClass.php';
     $pr=new Product();
     $result=   $pr->getStoreProduct($StID);
      if(!isset($_SESSION))
     {
         session_start();
         
      }
   if(isset($_SESSION['login']))

      {
       if($_SESSION['store_id']==$StID and $_SESSION['store_id']!=NULL)
       {
           $add=TRUE;
           $editpro=FALSE;
       }
       else{
           $editpro=true;
           $add=FALSE;
       }
 
}else {
    $editpro=true;
       $add=FALSE;    
       }
       
     include './storeProfile.php';
}
 else if(@$_GET['action']=="showProductInfo"){
       
    
     $proID= $_GET['Pid'];
    
    include './productClass.php';
     $pr=new Product();
     $result=   $pr->getProductByID($proID);
     $StID=$result[0]['stID'];
      if(!isset($_SESSION))
     {
         session_start();
         
      }
   if(isset($_SESSION['login']))

      {
       if($_SESSION['store_id']==$StID and $_SESSION['store_id']!=NULL)
       {
           $add=FALSE;
           $editpro=true;
       }
       else{
           $editpro=FALSE;
           $add=TRUE;
       }
 
}else {
    $editpro=FALSE;
       $add=TRUE;    
       }
      
     include './storeProfile.php';
}
?>